from PIL import Image, ImageDraw, ImageFont

# 创建画布
img = Image.new('RGB', (600, 300), color='white')
draw = ImageDraw.Draw(img)
font = ImageFont.load_default()

# 绘制排列与组合结果
draw.text((10, 10), "排列数: P(5, 3) = 60", fill="black", font=font)
draw.text((10, 50), "组合数: C(5, 3) = 10", fill="black", font=font)

# 保存图像
img_path = "permutation_combination.png"
img.save(img_path)
print(f"图形已保存为 {img_path}")